<template>
  <view class="login-page">
    <view class="login-box">
      <text class="title">登录</text>
      <view class="form-item">
        <text class="label">用户名</text>
        <input class="input" type="text" placeholder="请输入用户名" v-model="username" />
      </view>
      <view class="form-item">
        <text class="label">密码</text>
        <input class="input" type="password" placeholder="请输入密码" v-model="password" />
      </view>
      <button class="login-btn" @click="handleLogin">登录</button>
      <navigator url="/pages/register/register" class="register-link">没有账号？去注册</navigator>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      username: '',
      password: ''
    };
  },
  methods: {
    handleLogin() {
      if (!this.username || !this.password) {
        uni.showToast({
          title: '请输入用户名和密码',
          icon: 'none'
        });
        return;
      }
      // 实际项目中可添加接口请求逻辑，此处仅作示例
      uni.showToast({
        title: '登录成功',
        icon: 'success'
      });
    }
  }
};
</script>

<style scoped>
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: #f5f5f5;
}
.login-box {
  width: 80%;
  background-color: #fff;
  padding: 40rpx;
  border-radius: 12rpx;
  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
}
.title {
  display: block;
  text-align: center;
  font-size: 36rpx;
  font-weight: bold;
  margin-bottom: 40rpx;
}
.form-item {
  margin-bottom: 30rpx;
}
.label {
  display: block;
  font-size: 28rpx;
  margin-bottom: 10rpx;
}
.input {
  width: 100%;
  height: 80rpx;
  border: 1rpx solid #ddd;
  border-radius: 6rpx;
  padding: 0 20rpx;
  box-sizing: border-box;
}
.login-btn {
  width: 100%;
  height: 80rpx;
  background-color: #007aff;
  color: #fff;
  border-radius: 6rpx;
  margin-top: 20rpx;
}
.register-link {
  display: block;
  text-align: center;
  font-size: 28rpx;
  color: #007aff;
  margin-top: 30rpx;
}
</style>
